/* 
 * assert.h
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is a part of the clang port package.
 * No warranty is given; refer to the file DISCLAIMER within the package.
 *
 * Define the assert macro for debug output.
 *
 */

#ifndef _CLANG_PORT_ASSERT_H
#define _CLANG_PORT_ASSERT_H

/* All the headers include this file. */
#ifndef __IMPL_CLANG_PORT_API_
#	include <_clang_port.h>
#else
#	include <include/_clang_port.h>
#endif //__IMPL_CLANG_PORT_API_

#undef assert

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef NDEBUG
/*
 * If not debugging, assert does nothing.
 */
#define assert(x)	((void)0)

#else /* debugging enabled */

/* 
 * Clang Hook Api.
*/
typedef void *CLANG_PORT_FPTR_TYPE(assert)(const char*, const char*, int);
extern CLANG_PORT_FPTR_VAR(assert);

/*
 * STD C Api.
 */
#define assert(e)       ((e) ? (void)0 : CLANG_PORT_CALL_FPTR(assert)(#e,__FILE__,__LINE__ ) )

#endif	/* NDEBUG */

#ifdef	__cplusplus
}
#endif

#endif /* _CLANG_PORT_ASSERT_H */
